package app1

import (
	"context"
	pb "training-camp/week4/api/app1/v1"
	prdBiz "training-camp/week4/internal/biz/app1"
)

type ProdService struct {
}

func (ps *ProdService) GetProductStock(ctx context.Context, request *pb.ProductRequest) (*pb.ProductResponse, error) {
	prd := prdBiz.New()
	stock, err := prd.GetStock(request.ProdId)
	resp := pb.ProductResponse{
		ProdStock: stock,
		Code:      200,
		Message:   "",
		Reason:    "",
	}
	if err != nil {
		resp.Code = 404
		resp.Message = "Stock error"
		resp.Reason = ""
	}
	return &resp, err
}
